require "util";
require "logUtil";
require "setting"
-- 牢房
laoFang={}

function laoFang.ui()
  x, y = findMultiColorInRegionFuzzy(0xa76927,"-16|20|0x83471a,15|17|0x85481a,-42|11|0x000000,-7|48|0x000000,12|47|0x000000,-16|100|0x48220d,-420|30|0xd79859,-448|18|0xc7793d,-497|12|0xcb7c3c,-497|29|0xcc8147,-496|-1|0xbf6625,-423|-13|0xb95815,-419|8|0xe1a55e,-464|135|0x111015", 85, 455, 57, 1079, 227, 0, 0)

  if x > -1 then
    logger("牢房.界面", LOG_DEBUG)
    return true
  end
end

function  laoFang.close()
  x, y = findMultiColorInRegionFuzzy(0xa76927,"-16|20|0x83471a,15|17|0x85481a,-42|11|0x000000,-7|48|0x000000,12|47|0x000000,-16|100|0x48220d,-420|30|0xd79859,-448|18|0xc7793d,-497|12|0xcb7c3c,-497|29|0xcc8147,-496|-1|0xbf6625,-423|-13|0xb95815,-419|8|0xe1a55e,-464|135|0x111015", 85, 455, 57, 1079, 227, 0, 0)
  if x > -1 then
    click(x, y)
    logger("牢房.界面关闭", LOG_DEBUG)
    return true
  end

end

function laoFang.fanRen()
  click(533,967)
end

-- 查找烦人
function  lf_findfanRen()
  x, y = findMultiColorInRegionFuzzy(0xd8cf7f,"69|0|0xd8cf7f,68|105|0xf9ee8c,-64|103|0xe2d980,-97|45|0xf3f0a9,-61|48|0xfefab1,15|42|0xe9e6a4,58|49|0x817a5d", 86, 0, 0, 1079, 1919, 0, 0)
  if x > -1 then
    click(x, y)
    logger("牢房.烦人", LOG_DEBUG)
    return true
  end
end

--名望不足
function laoFang.mingWangBuZhu()
  x, y = findMultiColorInRegionFuzzy(0xfff1df,"23|-22|0xfff1df,-1|-24|0xfff1df,83|-19|0xfff1df,62|3|0xfff1df,62|20|0xfff1df,118|-10|0xfff1df,134|-1|0xfff1df,177|-8|0xfff1df,179|5|0xfff1df,177|19|0xfff1df,51|-69|0x06070a,152|-69|0x0c0806,-53|65|0x030304,252|64|0x050504", 85, 277, 795, 892, 1128, 0, 0)
  if x > -1 then
    logger("牢房.名望不足", LOG_DEBUG)
    return true
  end
end



function laoFang.run()
  ZhuJieMian.laoFang()
  mSleep(300)
  click(19,1479)
  mSleep(2000)
  flag=laoFang.ui()
  if  not(flag) then
    return
  end

  while true do

    laoFang.fanRen()
    mSleep(100)

    flag= laoFang.mingWangBuZhu()
    if flag then
      break
    end
    wangLuoLianJieShiBai()
  end
  laoFang.close()

end


